package com.httpDemo.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * web三大组件之一：Filter过滤器
 * 
 * @author 86173
 *
 */
public class MyFilter implements Filter {

	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		Filter.super.init(filterConfig);
		// 获取注入的初始化参数
		String value = filterConfig.getInitParameter("key");
		System.out.println("value:" + value);
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		System.out.println("----------doFilter---------");
		// 放行
		chain.doFilter(request, response);
	}

}
